package com.atguigu.gulimall.feign.retry;

import feign.RetryableException;
import feign.Retryer;


/**
 * @author nicc
 * @version 1.0
 * @className MyRetryer
 * @date 2022-10-23 16:26
 */
public class MyNeverRetryer implements Retryer {
    int start = 1;
    int end = 10;

    //决定重试器是否工作
    @Override
    public void continueOrPropagate(RetryableException e) {
        //System.out.println("重试器开始工作");

        //永不重试
        throw e;

        //throw e; //无限次重试

        //有限次重试

//        if(start++ > end){
//            throw e;
//        }

        //控制间隔
//        try {
//            Thread.sleep(500);
//        } catch (InterruptedException ex) {
//            throw new RuntimeException(ex);
//        }
    }

    @Override
    public Retryer clone() {
        return null;
    }
}
